package com.net.common.util;

import java.io.IOException;
import java.net.ServerSocket;

public class HttpUtils {
    /**
     * 获取服务器可用端口
     *
     * @return port
     */
    public static Integer getPort() {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(0);
            return serverSocket.getLocalPort();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            CloseableUtils.close(serverSocket);
        }
        return null;
    }
}
